﻿# // ***************************************************************************
# // 
# // Copyright (c) Scriptimus Ex Machina.  All rights reserved.
# // 
# // Microsoft Deployment Toolkit Support Script
# //
# // File:      ZTINew-HostARecord.ps1
# // 
# // Version:   1.00 
# // 
# // Purpose:   Creates DNS Host A records
# // 
# // ***************************************************************************

<#
.SYNOPSIS 
Lite-Touch Deployment script to Create a DNS Host A Record

.DESCRIPTION
The ZTINew-HostARecord.ps1 script will create a new Host A Resource Record on a DNS Server.

.PARAMETER $DnsServerName
Name of the DNS Server on which the A Record should be created. The default is the local server.

.PARAMETER $ContainerName
Name of the container into which the new A Record should be placed. The default is the current DNS domain

.PARAMETER $HostName
The Hostname of the A Record to be created

.PARAMETER $HostAddress
The IPAddress of the A Record to be created

.EXAMPLE
%SCRIPTROOT%\ZTINew-HostARecord.ps1 -HostName crl -HostAddress 10.0.0.3
Add this line to your add powershell task sequence to create a Host A Record on the local DNS Server

.NOTES
Author: Andrew Barnes
Date: 17 September 2012

.LINK
Online version: http://scriptimus.wordpress.com

#>

Param(

    [string]$DnsServerName = 'Localhost',

    [string]$ContainerName = "$env:USERDNSDOMAIN",

    [string]$HostName,

    [IPAddress]$HostAddress   

)

Begin{
    
    Write-Host "Begining script"
    
    }

Process{
    
    Write-Host "Processing Script"

    # Set Windows Management Instrumentation Class

    $Record = [WmiClass]"\\$DnsServerName\root\MicrosoftDNS:MicrosoftDNS_ResourceRecord"  

    # Construct Resource Record

    $RR = "$HostName.$ContainerName IN A $HostAddress"  

    # Create Host Record

    $Record.CreateInstanceFromTextRepresentation($DnsServerName, $ContainerName, $RR)  

}

End{

    Write-Host "End Script"
    
    }
